package com.njit.springboot.controller;

import com.bean.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping(value = "/index")
public class IndexController {

    @Value(value = "${roncoo.secret}")
    private String secret;

    @RequestMapping()
    public String index() {
        return "hello world";
    }

    @RequestMapping(value = "/get")
    public Map<String, String> get(@RequestParam String name) {
        Map<String, String> map = new HashMap<>();
        map.put("name", name);
        map.put("value", "hello world");
        map.put("secret",secret);
        return map;

    }

    @RequestMapping(value = "/find/{id}/{name}")
    public User get(@PathVariable Integer id, @PathVariable String name) {
        User u = new User();
        u.setId(id);
        u.setName(name);
        return u;
    }
}
